package com.douwong.student.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.model.Prepare;

import java.util.ArrayList;


public class PrepareAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<Prepare> list;
	public PrepareAdapter(Context context, ArrayList<Prepare>list){
		this.context=context;
		this.list=list;
		
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder=null;
		if(convertView==null){
			holder=new Holder();
			convertView=LayoutInflater.from(context).inflate(R.layout.prepare_item, null);
			holder.name_text=(TextView) convertView.findViewById(R.id.name_text);
			holder.subject_text=(TextView) convertView.findViewById(R.id.subject_text);
			holder.resource_count_text=(TextView) convertView.findViewById(R.id.resource_count_text);
			holder.createTime_text=(TextView) convertView.findViewById(R.id.create_time_text);
			convertView.setTag(holder);
		}else {
			holder=(Holder) convertView.getTag();
		}
		if(list.size()>0){
			holder.name_text.setText(list.get(position).getLessonName());
			holder.resource_count_text.setText(list.get(position).getDesCount()+"");
			holder.subject_text.setText(list.get(position).getSubjectName()+"\t"+list.get(position).getUserName());
			holder.createTime_text.setText(list.get(position).getCreatetime());
		}
		return convertView;
	}
	class Holder{
		TextView name_text,resource_count_text,subject_text,createTime_text;
	}

}
